package WebRoot.demo7;

import java.io.IOException;

import org.hoyi.DB.CLuster.DataBaseCluster;
import org.hoyi.DB.Interface.IDatabase;
import org.hoyi.dishop.Hoyipage;
import org.hoyi.wb.comment.RequestMode;
import org.hoyi.wb.comment.RequestType;

import WebRoot.demo2.entity.user;

public class DemoCtr extends Hoyipage{

	
	@RequestMode(MODE={RequestType.POST,RequestType.GET})
	public void alltype() throws IOException {

		String userid = this.getParams("userid");
		String type = this.getParams("type");
		String token = this.getParams("token");
		
		this.WriteUTF8HTML("userid:" + userid + ", type:" + type + " , token:" + token);
	}
	
	@RequestMode(MODE={RequestType.POST,RequestType.GET})
	public void transTest() throws IOException {

		IDatabase database = DataBaseCluster.Get_WRITE_SERVER();
		database.BeginTransaction();
		
		try {
			user u = new user();
			u.Insert(database);
			database.Commit();
		} catch (Exception e) {
			// TODO: handle exception
			database.RollBackTransaction();
		}finally{
			database.CloseConnection();
		}
	
	}
}
